<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello React!</title>
<!-- react核心库 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<!-- 支持react操作DOM -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<!-- 引入Babel，用于将JSX转换为JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<!-- prop-types -->
<script src="https://unpkg.com/prop-types@15.7.2/prop-types.js"></script>

</head>
<body>
<div id="test"></div>
<script type="text/babel"> 
    //生命周期回调函数，生命周期钩子函数 
    class Count extends React.Component{
       
        state = {count:0}

        add = () => {
            this.setState({count:this.state.count+1})
        }

        //初始化渲染，状态更新之后调用
        render(){
            return(
                <div>
                    <h2>当前求和为:{this.state.count}</h2>
                    <button onClick={this.add}>点我+1</button>
                </div>
            )
        }
    }
    ReactDOM.render(<Count/>,document.getElementById('test'))
</script>
</body>
</html>